import RSA from '@/utils/crypto/RSA'
import AES from '@/utils/crypto/AES'

export default class CryptoUtils {
  private static readonly _RSA = (async () => await RSA.initRSA('MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC59ckh0QcJmKHoaC5UEeT6K41WxVWbG5F84uHvKBof6w3rPVOc0cZZWcZMxokfFVVyX9BWRSiTFpyVkrcPkDBFFSfMcoOUMfS/s5WRh+omtO8FvkxzC4lDGw+w7LJNR1lLowVbmQoF1mHugGByz1B5MS0Mtv3zpUXMzqfy0YOj+QIDAQAB'))()
  private static readonly _AES = (async () => await AES.initAES("BTCNiEGPTlCWZFJLr1efow==","MQ=="))()

  public static async exportRSAPublicKey() {
    return (await (this._RSA)).exportPublicKey()
  }

  public static async exportRSAPrivateKey() {
    return (await (this._RSA)).exportPrivateKey()
  }

  public static async rsaEncrypt(data: string): Promise<string> {
    return (await (this._RSA)).encryptData(data)
  }

  public static async rsaDecrypt(encryptedHex: string): Promise<string> {
    return (await (this._RSA)).decryptData(encryptedHex)
  }

  public static async aesEncrypt(data: string): Promise<string> {
    return (await (this._AES)).encryptData(data)
  }

  public static async aesDecrypt(encryptedHex: string): Promise<string> {
    return (await (this._AES)).decryptData(encryptedHex)
  }

  public static async exportAESKey() {
    return (await (this._AES)).exportKey()
  }

  public static async exportAESIV() {
    return (await (this._AES)).exportIV()
  }
}